<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>

  <body>
    <h2>axios的GET请求带参数的形式</h2>
    <input type="text" />

    <button>测试</button>

    <ul></ul>
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
    <script>
      document.querySelector('button').onclick = async function () {
        const citys = document.querySelector('input').value
        const {
          data: { data },
        } = await axios({
          url: 'http://ajax-api.itheima.net/api/city?pname=' + citys,
          method: 'get',
        })
        document.querySelector('ul').innerHTML = data
          .map((item) => {
            return `<li>${item}</li>  `
          })
          .join('')
      }
    </script>
  </body>
</html>
